﻿<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>${setting.siteName} - 预约表管理</title>
    <meta name="keywords" content="${setting.siteName}">
    <meta name="description" content="${setting.siteName}">

    <!-- BEGIN HEADER -->
    [#include "/admin/include/style.ftl"]
    <!-- END HEADER -->
    <style type="text/css">
        .btn {
            margin: 0 5px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <form id="listForm" action="list.jhtml" method="get">
                    <div class="ibox-title">
                        <h5>预约表管理 </h5>
                        <div class="ibox-tools">
                            <a class="btn btn-outline btn-success btn-xs" id="btn-add-loippi" href="add.jhtml"><i
                                        class="fa fa-plus"></i> 新增</a>
                            <a class="btn btn-outline btn-danger btn-xs btn-delete-loippi-group"><i
                                        class="fa fa-trash"></i> 删除</a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="form-group">
                                <input type="text" id="keyword" name="keyword"
                                       class="form-control-static col-sm-6 offset2" placeholder="请输入医生名称，患者姓名搜索">
                                <button type="submit" class="btn btn-sm btn-primary loippi-search-button col-sm-1"> 搜索
                                </button>
                                <button type="reset" class="btn btn-sm btn-info col-sm-1">重置</button>
                            </div>
                        </div>
                        <div class="dataTables_wrapper form-inline">
                            <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                                <thead>
                                <tr>
                                    <th><input type="checkbox" class="i-checks" name="checkAll"></th>
                                    <th>预约号</th>
                                    <th>是否删除</th>
                                    <th>科室名称</th>
                                    <th>患者姓名</th>
                                    <th>预约医生</th>
                                    <th>预约时间</th>
                                    <th>支付状态</th>
                                    <th>预约状态</th>
                                    <th>预约类型</th>
                                    [#--                                    <th>就诊状态</th>--]
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                [#list page.content as subscribe]
                                    <tr>
                                        <td>
                                            <input type="checkbox" class="i-checks" name="ids" value="${subscribe.id}">
                                        </td>
                                        <td>${(subscribe.subscribeNu)!''}</td>
                                        <td>${(((subscribe.isDelete)!'') == 0)?string('否', '是')}</td>
                                        <td>${(subscribe.department.name)!''}</td>
                                        <td>${(subscribe.patient.name)!''}</td>
                                        <td>${(subscribe.doctor.name)!''}</td>
                                        <td>${(subscribe.subscribeTime?string('yyyy-MM-dd HH:mm:ss'))!''}</td>
                                        <td>${(((subscribe.payStatus)!'') == 0)?string('未支付', '已支付')}</td>
                                        <td>
                                            [#switch subscribe.status]
                                                [#case 0]
                                                    取消
                                                    [#break]
                                                [#case 1]
                                                    待就诊
                                                    [#break]
                                                [#case 2]
                                                    进行中
                                                    [#break]
                                                [#case 3]
                                                    已完成
                                                    [#break]
                                                [#case 4]
                                                    待确认
                                                    [#break]
                                            [/#switch]
                                        </td>
                                        <td>${(((subscribe.type)!'') == 0)?string('首次预约', '复诊')}</td>
                                        [#--                                        <td>${(((subscribe.subscribeStatus)!'') == 0)?string('待就诊',((subscribe.subscribeStatus) == 1)?string('进行中', '已就诊'))}</td>--]
                                        [#--					                        <td>${(subscribe.subscribeType)!''}</td>--]
                                        <td>
                                            <a href="${base}/admin/subscribe/view/${subscribe.id}.jhtml"
                                               class="btn btn-xs btn-default"> ${message("admin.common.view")} </a>
                                            [#--					                        	<a class="btn btn-info btn-xs btn-edit-loippi" data-id="${subscribe.id}" href="edit/${subscribe.id}.jhtml" ><i class="fa fa-paste"></i> ${message("admin.common.edit")} </a>--]
                                            [#--                                            <a class="btn btn-danger btn-xs btn-delete-loippi"--]
                                            [#--                                               data-id="${subscribe.id}"><i--]
                                            [#--                                                        class="fa fa-trash"></i> ${message("admin.common.delete")} </a>--]
                                            [#if subscribe.payStatus == 1 && subscribe.status = 1]
                                                <a style="display: none"
                                                   class="btn btn-danger btn-xs btn-confirm-loippi"
                                                   onclick="confirmSubscribe(${subscribe.id})"><i
                                                            class="fa fa-check-circle-o"></i> 确认就诊 </a>
                                            [/#if]
                                            [#if subscribe.status == 2]
                                                <a class="btn btn-danger btn-xs btn-confirm-loippi"
                                                   onclick="finishSubscribe(${subscribe.id})"><i
                                                            class="fa fa-check"></i> 完成就诊 </a>
                                            [/#if]
                                        </td>
                                    </tr>
                                [/#list]
                                </tbody>
                            </table>
                            [@pagination pageNumber = page.pageNumber totalPages = page.totalPages]
                                [#include "/admin/include/pagination.ftl"]
                            [/@pagination]
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- BEGIN Script -->
[#include "/admin/include/script.ftl"]
<!-- END Script -->

<script>

    $(document).ready(function () {
        [@flash_message /]
    });

    // 确认预约
    function confirmSubscribe(id) {
        alert(id);
        $.ajax({
            url: "${base}/admin/subscribe/confirm/" + id + ".jhtml",
            type: "GET",
            dataType: "json",
            cache: false,
            success: function (message) {
                window.setTimeout(function () {
                    window.location.reload();
                }, 1000);
            }
        });
    };

    // 完成预约
    function finishSubscribe(id) {
        $.ajax({
            url: "${base}/admin/subscribe/finish/" + id + ".jhtml",
            type: "GET",
            dataType: "json",
            cache: false,
            success: function (message) {
                window.setTimeout(function () {
                    window.location.reload();
                }, 1000);
            }
        });
    };
</script>
</body>

</html>
